#ifndef __TASK_QUEUE_H__
#define __TASK_QUEUE_H__

#include "MutexLock.h"
#include "Condition.h"
#include <pthread.h>
#include <queue>
#include <functional>

using std::queue;

namespace myNameSpace {
using TaskCallback = std::function<void()>;
class TaskQueue {
public:
    using ElemType = TaskCallback;
    TaskQueue(size_t queueSize);
    ~TaskQueue() = default;

    void push(ElemType &&taskCallback);
    ElemType pop();

    void wakeUp();

    bool empty();

private:
    bool full();

private:
    queue<ElemType> _queue;
    size_t _queueSize;
    MutexLock _mutex;
    Condition _notFull;
    Condition _notEmpty;
    bool _isWorking;
};
} // end of namespace myNameSpace

#endif

